package com.cloud.common.utils;


import com.cloud.common.constant.HttpStatusEnum;
import lombok.Data;

import java.io.Serializable;

@Data
public  class UserResult implements Serializable {

    private static final long serialVersionUID = -430305211620084335L;

    private int status;
    private String msg;
    private Object data;

    public UserResult() {
    }

    public UserResult(String msg) {
        this.msg = msg;
    }

    public UserResult(int status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public UserResult(int status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }



    public static UserResult success(String msg, Object data){
        return new UserResult(HttpStatusEnum.OK.code(),msg,data);
    }

    public static UserResult success(String msg){
        return new UserResult(HttpStatusEnum.OK.code(),msg);
    }

    public static UserResult error(ResultMsg resultMsg, String msg, Object data){
        return new UserResult(resultMsg.getCode(),resultMsg.getMsg(),data);
    }

    public static UserResult error(String msg){
        return new UserResult(HttpStatusEnum.INTERNAL_SERVER_ERROR.code(),msg);
    }
}
